package com.heima.file.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
@EnableConfigurationProperties(MinIoProperties.class)
public class MinIoAutoConfiguration {

    @Autowired
    MinIoProperties minIoProperties;


    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .credentials(minIoProperties.getAccessKey(),minIoProperties.getSecretKey())
                .endpoint(minIoProperties.getEndpoint())
                .build();
    }
}
